package com.itls.recommendedgames.control;

import com.itls.recommendedgames.entity.User;
import com.itls.recommendedgames.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/user")
@CrossOrigin
@Tag(name = "用户管理")
public class UserController {
    @Resource
    private UserService userService;
    @PostMapping("/register")
    @Operation(summary = "用户注册")
    public void insert(@RequestBody User user) {

        userService.insertUser(user);
    }


    @PostMapping("/login")
    @Operation(summary = "用户登录")
    public User find(@RequestBody  User user) {
        System.out.println("收到登录请求，username: " + user.getUsername() + ", password: " + user.getPassword());
        return userService.find(user);
    }

}